﻿@model Gtkj.CMS.Model.Summary
@{
    if (Model.Id == 0)
    {
        ViewBag.Title = "添加今日汇总";
    }
    else
    {
        ViewBag.Title = "修改汇总数据";
    }
    Layout = "~/Views/Shared/Master.cshtml";
}

<div class="page-content-wrapper">
    <!-- BEGIN CONTENT BODY -->
    <div class="page-content">
        <!-- BEGIN PAGE HEADER-->
        <div class="page-bar">
            <ul class="page-breadcrumb">
                <li>
                    <a href="/Home/Main">首页</a>
                    <i class="fa fa-angle-double-right"></i>
                </li>
                <li>
                    <span>每日汇总</span>
                </li>
            </ul>
        </div>
        <h3 class="page-title">
            每日汇总<span><a class="btn btn-success " href="javascript:;" onclick="history.go(-1);"><span class="icon-action-undo" aria-hidden="true" style="float:left; margin-top:3px; margin-right:4px"></span> 返回</a></span>
        </h3>
        <!-- BEGIN PAGE TITLE-->
        <div class="portlet light bordered">
            <div class="portlet-title">
                <div class="caption"><i class="icon-settings font-yellow-casablanca"></i><span class="caption-subject bold font-yellow-casablanca">输入汇总数据</span></div>
            </div>
            <!--添加代码开始-->
            <div class="portlet-body form">
                <!-- BEGIN FORM-->
                <form action="#" id="AddOrderForm" method="post" class="form-horizontal layui-form">
                    <input hidden="hidden" type="text" id="LastDaySummaryId" name="LastDaySummaryId" value="@ViewData["LastDaySummaryId"]" />
                    @Html.HiddenFor(e => e.Id)
                    @Html.HiddenFor(e => e.CreateUserId)
                    <div class="form-body">

                        <div class="form-group">
                            <label class="control-label col-md-3">
                                添加时间<span class="required"> * </span>
                            </label>
                            <div class="col-md-4">
                                <input type="text" value="@ViewData["MyDate"]" name="CreateTime" id="CreateTime" data-required="1" lay-verify="required|date" class="form-control" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-3">
                                今日加粉数<span class="required"> * </span>
                            </label>
                            <div class="col-md-4">
                                <input type="text" name="TodayFansNum" id="TodayFansNum" data-required="1" value="@Model.TodayFansNum" lay-verify="required|number" class="form-control" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-3">
                                今日对话数<span class="required"> * </span>
                            </label>
                            <div class="col-md-4">
                                <input type="text" name="TodayTalkNum" id="TodayTalkNum" data-required="1" value="@Model.TodayTalkNum" lay-verify="required|number" class="form-control" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-3">
                                新粉出单数<span class="required"> * </span>
                            </label>
                            <div class="col-md-4">
                                <input type="text" name="NewFansOrderNum" id="NewFansOrderNum" data-required="1" value="@Model.NewFansOrderNum" lay-verify="required|number" class="form-control" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-3">
                                老粉出单数<span class="required"> * </span>
                            </label>
                            <div class="col-md-4">
                                <input type="text" name="OldFansOrderNum" id="OldFansOrderNum" data-required="1" value="@Model.OldFansOrderNum" lay-verify="required|number" class="form-control" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-3">
                                体验装出单<span class="required"> * </span>
                            </label>
                            <div class="col-md-4">
                                <input type="text" name="SampleOrderNum" id="SampleOrderNum" data-required="1" value="@Model.SampleOrderNum" lay-verify="required|number" class="form-control" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-3">
                                体验装转正<span class="required"> * </span>
                            </label>
                            <div class="col-md-4">
                                <input type="text" name="SampleToForMalOrderNum" id="SampleToForMalOrderNum" data-required="1" value="@Model.SampleToForMalOrderNum" lay-verify="required|number" class="form-control" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-3">
                                复购<span class="required"> * </span>
                            </label>
                            <div class="col-md-4">
                                <input type="text" name="RePurchaseOrderNum" id="RePurchaseOrderNum" data-required="1" value="@Model.RePurchaseOrderNum" lay-verify="required|number" class="form-control" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-3">
                                今日数据量<span class="required"> * </span>
                            </label>
                            <div class="col-md-4">
                                <input type="text" name="TodaySumNum" id="TodaySumNum" data-required="1" value="@Model.TodaySumNum" lay-verify="required|number" class="form-control" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-3">
                                昨日数据量<span class="required"> * </span>
                            </label>
                            <div class="col-md-4">
                                <input type="text" name="LastDaySumNum" id="LastDaySumNum" data-required="1" value="@ViewData["LastDaySumNum"]" lay-verify="required|number" class="form-control" />
                            </div>
                        </div>
                    </div>

                    <div class="form-actions">
                        <div class="row">
                            <div class="col-md-offset-3 col-md-9">
                                @*<a href="#" class="btn btn-primary" > <span class="glyphicon glyphicon-ok"> </span> 提交 </a>*@
                                <button type="button" lay-submit class="btn btn-primary" onclick="AddSummaryOn();"><span class="glyphicon glyphicon-ok"> </span> 提交</button>
                                <button type="button" class="btn default" onclick="history.go(-1);"><span class="glyphicon glyphicon-remove"> </span> 取消</button>
                            </div>
                        </div>
                    </div>
                </form>
                <!-- END FORM-->
            </div>
        </div>
        <!--添加代码结束-->
    </div>
</div>
<script>
    var imgnum;
    layui.use('laydate', function () {
        var laydate = layui.laydate;


        //执行一个laydate实例
        laydate.render({
            elem: '#CreateTime'
            //指定元素
        });
    });
</script>
<script>

    $(function () {
            @*var mydate="@ViewData["MyDate"]";
            $("#CreateTime").val(mydate);*@
    });

    function AddSummaryOn() {
        if (isNaN($("#TodayFansNum").val())
            || isNaN($("#TodayTalkNum").val())
            || isNaN($("#NewFansOrderNum").val())
            || isNaN($("#OldFansOrderNum").val())
            || isNaN($("#SampleOrderNum").val())
            || isNaN($("#SampleToForMalOrderNum").val())
            || isNaN($("#RePurchaseOrderNum").val())) {

        }
        $.ajax({
            url: "/Home/AddSummaryOn",
            type: "post",
            data: $("#AddOrderForm").serialize(),
            success: function (result) {
                if (result.success) {
                    layer.msg("操作成功！", { icon: 1 });
                    setTimeout(function myfunction() {
                        history.go(-1);
                    },1500);
                } else {
                    layer.msg(result.msg, {icon:2});
                }
            }
        });
    }
</script>

